package com.asia5b.a5mall.middleware.model.goods

import android.text.TextUtils
import com.asia5b.a5mall.middleware.model.base.BaseModel
import java.io.Serializable
import java.util.*

/**
 * Created by zhangyuncai on 2020/1/16.
 */
class Goods2SkuModel : BaseModel() {
    //    var self_operated = ""//todo 这个字段后台返回有问题,禁止使用
    var sku_id = 0
    var goods_id = 0

    //库存
    var enable_quantity = 0
    var goods_name = ""
    var seller_name = ""
    var seller_id = 0
    var sn = ""
    var price = 0.0
    var price_list: HashMap<String, Double>? = null
    var spec_list: ArrayList<Goods2SpecModel>? = null
    var thumbnail=""

    var spec_value_id_list = arrayListOf<Int>()
        get() {
            field.clear()
            spec_list?.forEach {
                field.add(it.spec_value_id)
            }
            return field
        }
    var spec_value_id_list_text = ""
        get() {
            if (field.isEmpty()) {
                val idList = arrayListOf<Int>()
                spec_list?.forEach {
                    idList.add(it.spec_value_id)
                }
                if (!idList.isNullOrEmpty()) {
                    field = idList.toString()
                }
            }
            return field
        }
    var spec_value_list_text = ""
        get() {
            if (field.isEmpty()) {
                val valueList = arrayListOf<String>()
                spec_list?.forEach {
                    valueList.add("${it.spec_value}")
                }
                if (!valueList.isNullOrEmpty()) {
                    field = TextUtils.join(" ", valueList)
                }
            }
            return field
        }
}

class Goods2SpecModel : BaseModel() {
    var spec_id = 0
    var spec_value=""
    var spec_name=""
    var spec_value_id = 0

    var bgState = 0//背景状态 0:可以点击&没有选中 1可以点击&被选中 2不可以点击,默认可点击
    var thumbnail=""
}

/*
{
    "spec_id": 2622,
    "spec_value": "1 套 = 40 件",
    "seller_id": null,
    "spec_name": "包装",
    "sku_id": null,
    "big": "",
    "small": "",
    "thumbnail": "",
    "tiny": null,
    "spec_type": 1,
    "spec_image": null,
    "spec_value_id": 10136
}
 */

/*
{
    "sku_id": 24095,
    "goods_id": 8211,
    "goods_name": "木柄硅胶平底锅漏铲煎铲",
    "sn": "600271",
    "quantity": 0,
    "enable_quantity": -400,
    "price": 6.38,
    "price_list": {
        "price_rmb": 6.38,
        "price_myr": 3.78,
        "price_thb": 27.34,
        "price_idr": 12720.47,
        "price_vnd": 21034.56,
        "price_php": 45.77
    },
    "mktprice": 0,
    "cost": 5.8,
    "weight": 0.09,
    "tare_weight": 0.01,
    "seller_id": 64,
    "seller_name": "全广州最靓的店",
    "category_id": 656,
    "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg\/A
    "hash_code": 1051730264,
    "goods_long": 32,
    "goods_width": 7,
    "goods_height": 2,
    "package_long": 66,
    "package_width": 45,
    "package_height": 41,
    "goods_warning_count": 0,
    "real_quantity": 9999,
    "units_number": 40,
    "insufficient_number": 0,
    "box_number": 0,
    "set_number": 0,
    "bulk_batch": 0,
    "pieces_number": 1,
    "units": "",
    "template_id": null,
    "spec_list": [
        {
            "spec_id": 2622,
            "spec_value": "1 套 = 40 件",
            "seller_id": null,
            "spec_name": "包装",
            "sku_id": null,
            "big": "",
            "small": "",
            "thumbnail": "",
            "tiny": null,
            "spec_type": 1,
            "spec_image": null,
            "spec_value_id": 10136
        }
    ],
    "goods_transfee_charge": null,
    "disabled": null,
    "market_enable": null,
    "goods_type": null,
    "last_modify": null,
    "traits_id": null,
    "traits_name": null,
    "purchase_quantity": null,
    "total_prices": null,
    "total_prices_list": {
        "price_rmb": 0,
        "price_myr": 0,
        "price_thb": 0,
        "price_idr": 0,
        "price_vnd": 0,
        "price_php": 0
    },
    "self_operated": null
}
 */